import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { WrestleDateCellRenderer } from "./cellRendener/WrestleDateCellRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { FontUtil } from "../../../common/font/FontUtil";
import { Cache } from "../../cache/Cache";
import { MyWrestleInfo } from "./wrestleData/MyWrestleInfo";
import { WrestleDateData } from "./wrestleData/WrestleDateData";
import { GTileList } from "../../../../com/mui/controls/GTileList";
//class WrestleDateWindow
    
    export  class WrestleDateWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(514, 273);
            title = Language.getString(42294);
            titleHeight = 26;
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this.initDataArray();
            ObjCreate.createBg(18, 38, 247, 226, this);
            ObjCreate.createBg(269, 38, 227, 226, this);
            ObjCreate.createTextField(Language.getString(42295), 50, 51, 70, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(42296), 182, 51, 70, 20, this, GlobalStyle.textFormat6);
            this._tileList = ObjCreate.createTileList(34, 73, 224, 217, this);
            this._tileList.rowHeight = 31;
            this._tileList.columnWidth = 224;
            this._tileList.setStyle("cellRenderer", WrestleDateCellRenderer);
            this._tileList.dataProvider = new DataProvider(this._wrestleDataArray);
            var loc1=GlobalStyle.textFormatGreen;
            loc1.size = 14;
            loc1.bold = true;
            this._tfDate = ObjCreate.createTextField(Language.getString(42297), 315, 75, 150, 20, this, loc1);
            ObjCreate.createTextField(Language.getString(42298), 310, 117, 90, 20, this);
            ObjCreate.createTextField(Language.getString(42299), 310, 150, 90, 20, this);
            var loc2=GlobalStyle.textFormat6;
            loc2.font = FontUtil.EmbedNumberName;
            loc2.size = 25;
            this._tfLastScore = ObjCreate.createEmbedTextFiled("0", 402, 114, 80, 25, this, loc2);
            this._tfLastWrestle = ObjCreate.createEmbedTextFiled("0", 402, 147, 80, 25, this, loc2);
            var loc3=ObjCreate.createTextField("", 305, 208, 170, 20, this, GlobalStyle.textFormatGreen);
            loc3.htmlText = Language.getString(44566);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            var loc1=Cache.instance.wrestle.wrestleMyWrestleinfo;
            if (loc1) 
            {
                this.updateInfo(loc1);
            }
            return;
        }

        public updateInfo(arg1: MyWrestleInfo): void
        {
            if (arg1) 
            {
                if (arg1.isNewCross) 
                {
                    this._tileList.dataProvider = new DataProvider(this._wrestleDataArrayNewServer);
                }
                else 
                {
                    this._tileList.dataProvider = new DataProvider(this._wrestleDataArray);
                }
                if (arg1.ex) 
                {
                    this._tfLastScore.text = arg1.ex.lastDailyMark.toString();
                    this._tfLastWrestle.text = arg1.ex.lastDailyReward.toString();
                }
            }
            return;
        }

        /* internal  */initDataArray(): void
        {
            this._wrestleDataArray = [];
            this._wrestleDataArray.push(new WrestleDateData("10000-11999", "250~350"));
            this._wrestleDataArray.push(new WrestleDateData("12000-13999", "350~450"));
            this._wrestleDataArray.push(new WrestleDateData("14000-15999", "550~650"));
            this._wrestleDataArray.push(new WrestleDateData("16000-17999", "750~850"));
            this._wrestleDataArray.push(new WrestleDateData("18000~19999", "950~1050"));
            this._wrestleDataArray.push(new WrestleDateData("20000~25000", "1150~1350"));
            this._wrestleDataArrayNewServer = [];
            this._wrestleDataArrayNewServer.push(new WrestleDateData("8000-11999", "150~350"));
            this._wrestleDataArrayNewServer.push(new WrestleDateData("12000-13999", "350~450"));
            this._wrestleDataArrayNewServer.push(new WrestleDateData("14000-15999", "550~650"));
            this._wrestleDataArrayNewServer.push(new WrestleDateData("16000-17999", "750~850"));
            this._wrestleDataArrayNewServer.push(new WrestleDateData("18000~19999", "950~1050"));
            this._wrestleDataArrayNewServer.push(new WrestleDateData("20000~25000", "1150~1350"));
            return;
        }

        public static hasInstance(): Boolean
        {
            return !(WrestleDateWindow._instance == null);
        }

        public static get instance(): WrestleDateWindow
        {
            if (!WrestleDateWindow._instance) 
            {
                WrestleDateWindow._instance = new WrestleDateWindow();
            }
            return WrestleDateWindow._instance;
        }

        protected /* var */_wrestleDataArray: Array<any>;

        protected /* var */_wrestleDataArrayNewServer: Array<any>;

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_tfDate: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLastScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLastWrestle: Object /* flash.text.TextField */;

        /* internal */ static /* var */_instance: WrestleDateWindow;
    }
